library(learnr) here::here() knitr::opts_chunk$set(echo = FALSE)
The transplant study is located in the Gongga Mountains in Sichuan Province, south-west China. The study contains four sites spanning from 3000 to 4130 m a.s.l. along an elevational gradient. The vegetation ranges from coniferous-broadleaved forest to alpine meadows.
knitr::include_graphics("images/TransplantMap.png")
knitr::include_graphics("images/ChinaMountain.jpg")
First, is important to install all packages needed. The code in the file "setup.R" will do this and check you have a recent version of R.
Run this script first to check required packages installed
# Check recent version of R installed if(getRversion() < "3.6.0") { stop("##########\nOld version of R\nPlease install latest version\n##########") } # Check recent version of Rstudio installed if(RStudio.Version()$version < "1.0.1"){ stop("##########\nOld version of Rstudio\nPlease install latest version\n##########") } # Check CRAN packages installed CRAN_needed <- c( "tidyverse", #this includes dplyr, ggplot, tidyr etc "vegan", "RSQLite", "DBI", "remotes", "patchwork", "rmarkdown") # Check against currently installed packages installed_packages <- .packages(all.available = TRUE) CRAN_needed2 <- CRAN_needed[!CRAN_needed %in% installed_packages] # Download missing CRAN packages if(length(CRAN_needed2) > 0){ install.packages(CRAN_needed2) } # Install libraries from GitHub: remotes::install_github("gavinsimpson/ggvegan", upgrade = FALSE) remotes::install_github("Between-the-Fjords/dataDownloader", upgrade = FALSE) # Check all packages downloaded if this line doesn't work - assert that didn't install stopifnot(all(c(CRAN_needed, "ggvegan", "dataDownloader") %in% .packages(all.available = TRUE))) # clean-up rm(CRAN_needed, CRAN_needed2, installed_packages)
library("tidyverse") library("dataDownloader") library("DBI") library("vegan") library("ggvegan") library("patchwork")
Download the data and store it in the proper files
Instructions to download the Data
Location of PFTC Data:
The data are located in OSF repository
To know the exact location of each PFTC Data check this file: Here
China community data from the transplants:
get_file(node = "4hjzu", file = "transplant.sqlite", path = "community/data")
get_file(node = "emzgf", file = "PFTC1.2_China_2015_2016_LeafTraits.csv", path = "traits/data")
get_file(node = "emzgf", file = "PFTC1.2_China_2015_2016_ChemicalTraits.csv", path = "traits/data")
The script to read and process the cover data is in "hidden" folder:
source("hidden/start_here.R")
This script is going to:
We can either source it or run it step by step to see what is doing (preferred option). If you want to run it step by step then open the file.
The traits data are located in China/traits/data, in two files: LeafTraits and ChemicalTraits. To read the csv files:
traitsLeaf <- read_csv(file = "traits/data/PFTC1.2_China_2015_2016_LeafTraits.csv") traitsChem <- read_csv(file = "traits/data/PFTC1.2_China_2015_2016_ChemicalTraits.csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.